package com.hx.cmd;

import java.util.Vector;

import com.hx.shape.*;

public class CommandCenter {
	protected static CommandCenter singleton;
	protected int mode;
	Shape curShape;
	Vector<Shape> shapeList;
	
	public static final int LINEMODE = 0;
	public static final int OVALMODE = 1;
	public static final int RECTMODE = 2;
	
	public CommandCenter(){
		shapeList =new Vector<Shape>();
	}
	public static CommandCenter getInstance(){
		if(singleton == null){
			synchronized(CommandCenter.class){
				singleton =new CommandCenter();
			}
		}
		return singleton;
	}
	public void setDrawMode(int mode){
		this.mode = mode;
	}
	public Vector<Shape> getShapeList(){
		return shapeList;
	}
	public Shape getCurShape(){
		return curShape;
	}
	
	public void createShape(float x,float y){
		if(mode == LINEMODE)
			curShape = new HxLine(x,y);
		else if(mode == OVALMODE)
			curShape = new HxOval(x,y);
		else if(mode == RECTMODE)
			curShape = new HxRect(x,y);
	}
	public void modifyShape(float x,float y){
		curShape.setEndPoint(x, y);
	}
	public void finishShape(float x,float y){
		curShape.setEndPoint(x, y);
		shapeList.add(curShape);
		curShape = null;
	}
}
